﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using RegisterationCommon.Common;
using System.Collections.Specialized;

namespace RegisterationCommon.Contrast
{
    /// <summary>
    /// 对比信息实体操作类
    /// </summary>
   public class ContrastInfo
    {
        #region 局部变量
        private int _id;
        private string _ctname;
        private DateTime _ctbirthday;
        private bool _ctsex = true;
        private string _ctguardname;
        private string _ctguardrelation;
        private string _ctaddress;
        #endregion

        #region 属性列表
        public int ID
        {
            set { _id = value; }
            get { return _id; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string CtName
        {
            set { _ctname = value; }
            get { return _ctname; }
        }
        /// <summary>
        /// 
        /// </summary>
        public DateTime CtBirthday
        {
            set { _ctbirthday = value; }
            get { return _ctbirthday; }
        }
        /// <summary>
        /// 
        /// </summary>
        public bool CtSex
        {
            set { _ctsex = value; }
            get { return _ctsex; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string CtGuardName
        {
            set { _ctguardname = value; }
            get { return _ctguardname; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string CtGuardRelation
        {
            set { _ctguardrelation = value; }
            get { return _ctguardrelation; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string CtAddress
        {
            set { _ctaddress = value; }
            get { return _ctaddress; }
        }
        #endregion
        #region 方法列表
        #region 账号注册
        /// <summary>
        /// 学生登记
        /// </summary>
        /// <returns></returns>
        public bool AddNewStudentInfoCt()
        {
            RParams rp = new RParams();
            rp.Add("CtName", this._ctname, SqlDbType.NVarChar);
            rp.Add("CtBirthday", this._ctbirthday, SqlDbType.DateTime);
            rp.Add("CtSex", this._ctsex, SqlDbType.Bit);
            rp.Add("CtGuardName", this._ctguardname, SqlDbType.NVarChar);
            rp.Add("CtGuardRelation", this._ctguardrelation, SqlDbType.NVarChar);
            rp.Add("CtAddress", this._ctaddress, SqlDbType.NVarChar);
            //添加学生信息
            if (DBAction.Insert(ETableName.ContrastInfo, rp))
            {
                return true;
            }
            else
            {
                return false;
            }

        }
        #region 根绝ID查询学生信息
        /// <summary>
        /// 根绝ID查询学生对比信息
        /// </summary>
        /// <param name="stuID">学生编号</param>
        /// <returns>查询成功返回true,否则返回false</returns>
        public bool GetStudentsCtByID(int stuID)
        {
            DataTable dtst = DBAction.GetDTFromSQL("Select * From " + ETableName.Students + " where ID=" + stuID);
            if (dtst.Rows.Count < 1)
            {
                return false;
            }
            DataTable dt = DBAction.GetDTFromSQL("Select * From " + ETableName.ContrastInfo + " where CtName='" + dtst.Rows[0]["TrueName"] + "'");
            if (dt.Rows.Count < 1)
            {
                return false;
            }
            this.CtName = Convert.ToString(dt.Rows[0]["CtName"]);
            this.CtBirthday = Convert.ToDateTime(dt.Rows[0]["CtBirthday"]);
            this.CtSex = Convert.ToBoolean(dt.Rows[0]["CtSex"]);
            this.CtGuardName =Convert.ToString(dt.Rows[0]["CtGuardName"]);
            this.CtGuardRelation = Convert.ToString(dt.Rows[0]["CtGuardRelation"]);
            this.CtAddress = Convert.ToString(dt.Rows[0]["CtAddress"]);//户籍地址
            return true;
        }
        #endregion
        #endregion
        #endregion
    }
}
